home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / utils / clearmem.arc / bcmp.asm next >
Assembly Source File  |  1988-08-19  |  772b  |  39 lines

  1.  
  2.         public    _bcmp        ; compare two blocks of memory
  3.  
  4.         ;   BCMP(src, dst, len)
  5.         ;   char *src, *dst;
  6.         ;   long len;
  7.  
  8. _bcmp:        move.l    4(sp),A0
  9.         move.l    8(sp),A1
  10.         move.l    12(sp),D0
  11.         move.w    D0,D1        ;longword align address
  12.         neg.w    D1
  13.         and.w    #3,D1
  14.         cmp.w    D0,D0        ;force Z bit
  15.         bra    .bc2
  16. .bc1        cmpm.b    (A0)+,(A1)+
  17. .bc2        dbne    D1,.bc1
  18.         bne    .bcfail
  19.         move.l    D0,D1
  20.         lsr.l    #2,D1        ;# of longwords to compare
  21.         cmp.w    D0,D0        ;force Z bit
  22.         bra    .bc11
  23. .bc10        cmpm.l    (A0)+,(A1)+
  24. .bc11        dbne    D1,.bc10
  25.         bne    .bcfail
  26.         sub.l    #$10000,D0
  27.         bcc    .bc10
  28.         and.w    #3,D0        ;remaining bytes to compare
  29.         cmp.w    D0,D0        ;force Z bit
  30.         bra    .bc21
  31. .bc20        cmpm.b    (A0)+,(A1)+
  32. .bc21        dbne    D0,.bc20
  33.         bne    .bcfail
  34.         moveq.l #1,D0        ;success!
  35.         rts
  36. .bcfail     moveq.l #0,D0        ;failure!
  37.         rts
  38.  
  39.